# Description: main.py implements all steps to crawls, maps, and recommends the tags for some pages at lastfm
# Colaborators: Saulo Ricci
# Date: 2010/08/24

from crawler.insulation_crawler import insulation_crawler
from mapper.insulation_mapper import insulation_mapper
from rec.insulation_recommender import insulation_recommender
from settings import *
import time

def crawling(crawler):
	crawler.execute()
	for entry in crawler.output_set['output_files_list']:
		print entry
def mapping(mapper):
	mapper.execute()
	for entry in mapper.output_set['output_files_list']:
		print entry

def main():
	start_time = time.time()
	# Do crawl job
	crawler = insulation_crawler(CRAWLER_INPUT_DICT, CRAWLER_OUTPUT_DICT)
	crawling(crawler)

	# Do map job
	for entry in crawler.output_set['output_files_list']:
		MAPPER_INPUT_DICT['xml_filename_list'].append(entry)
	mapper = insulation_mapper(MAPPER_INPUT_DICT, MAPPER_OUTPUT_DICT)
	mapping(mapper)

	# Do recommend job
	for mapped_tuple in mapper.output_set['output_files_list']:
		RECOMMENDER_INPUT_DICT['test_inputtag_filename_list'].append(mapped_tuple)
	recommender = insulation_recommender(RECOMMENDER_INPUT_DICT, RECOMMENDER_OUTPUT_DICT)
	recommender.execute()
	for file in recommender.output_set['output_files_list']:
		print file
	
	end_time = time.time()
	print str(end_time - start_time)

if __name__ == "__main__":
	main()
